﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsControlLibrary1
{
    public partial class TapControl : UserControl
    {
        public TapControl()
        {
            InitializeComponent();
            this.Load += TapControl_Load;
        }

        private void TapControl_Load(object sender, EventArgs e)
        {
            if (actualValue)
            {
                mainPic.Image = Properties.Resources.阀门打开;
            }
            else
            {
                mainPic.Image = Properties.Resources.阀门关闭;
            }
        }

        private bool actualValue = false;
        public bool ActualValue
        {
            get { return actualValue; }
            set
            {
                actualValue = value;
                if (actualValue)
                {
                    mainPic.Image = Properties.Resources.阀门打开;
                }
                else
                {
                    mainPic.Image = Properties.Resources.阀门关闭;
                }
            }
        }

        public delegate void TapClickDelegate(object sender, EventArgs e);
        public event TapClickDelegate TapClick;

        private void mainPic_Click(object sender, EventArgs e)
        {
            if (TapClick!= null)
            {
                TapClick(sender, new EventArgs());
            }
        }
    }
}
